home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / J0R475 (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  2.9 KB  |  94 lines

  1. package com.sun.java.swing.plaf.basic;
  2.  
  3. import java.awt.Rectangle;
  4. import java.awt.event.FocusEvent;
  5. import java.awt.event.FocusListener;
  6. import java.awt.event.InputEvent;
  7. import java.awt.event.MouseAdapter;
  8. import java.awt.event.MouseEvent;
  9. import java.awt.event.MouseMotionListener;
  10. import java.io.Serializable;
  11.  
  12. class BasicListUI$InputListener extends MouseAdapter implements MouseMotionListener, FocusListener, Serializable {
  13.    // $FF: synthetic field
  14.    BasicListUI this$0;
  15.  
  16.    public void mousePressed(MouseEvent e) {
  17.       int row = this.this$0.convertYToRow(e.getY());
  18.       if (row != -1) {
  19.          this.this$0.list.setValueIsAdjusting(true);
  20.          int anchorIndex = this.this$0.list.getAnchorSelectionIndex();
  21.          if (((InputEvent)e).isControlDown()) {
  22.             if (this.this$0.list.isSelectedIndex(row)) {
  23.                this.this$0.list.removeSelectionInterval(row, row);
  24.             } else {
  25.                this.this$0.list.addSelectionInterval(row, row);
  26.             }
  27.          } else if (((InputEvent)e).isShiftDown() && anchorIndex != -1) {
  28.             this.this$0.list.setSelectionInterval(anchorIndex, row);
  29.          } else {
  30.             this.this$0.list.setSelectionInterval(row, row);
  31.          }
  32.       }
  33.  
  34.       if (!this.this$0.hasFocus) {
  35.          this.this$0.list.requestFocus();
  36.       }
  37.  
  38.    }
  39.  
  40.    public void mouseDragged(MouseEvent e) {
  41.       if (!((InputEvent)e).isShiftDown() && !((InputEvent)e).isControlDown()) {
  42.          int row = this.this$0.convertYToRow(e.getY());
  43.          if (row != -1) {
  44.             Rectangle cellBounds = this.this$0.getCellBounds(this.this$0.list, row, row);
  45.             if (cellBounds != null) {
  46.                this.this$0.list.scrollRectToVisible(cellBounds);
  47.                this.this$0.list.setSelectionInterval(row, row);
  48.             }
  49.          }
  50.  
  51.       }
  52.    }
  53.  
  54.    public void mouseMoved(MouseEvent e) {
  55.    }
  56.  
  57.    public void mouseReleased(MouseEvent e) {
  58.       if (!((InputEvent)e).isShiftDown() && !((InputEvent)e).isControlDown()) {
  59.          int row = this.this$0.convertYToRow(e.getY());
  60.          if (row != -1) {
  61.             this.this$0.list.setSelectionInterval(row, row);
  62.          }
  63.  
  64.          this.this$0.list.setValueIsAdjusting(false);
  65.       }
  66.    }
  67.  
  68.    protected void repaintCellFocus() {
  69.       int leadIndex = this.this$0.list.getLeadSelectionIndex();
  70.       if (leadIndex != -1) {
  71.          Rectangle r = this.this$0.getCellBounds(this.this$0.list, leadIndex, leadIndex);
  72.          if (r != null) {
  73.             this.this$0.list.repaint(r.x, r.y, r.width, r.height);
  74.          }
  75.       }
  76.  
  77.    }
  78.  
  79.    public void focusGained(FocusEvent e) {
  80.       this.this$0.hasFocus = true;
  81.       this.repaintCellFocus();
  82.    }
  83.  
  84.    public void focusLost(FocusEvent e) {
  85.       this.this$0.hasFocus = false;
  86.       this.repaintCellFocus();
  87.    }
  88.  
  89.    // $FF: synthetic method
  90.    BasicListUI$InputListener(BasicListUI this$0) {
  91.       this.this$0 = this$0;
  92.    }
  93. }
  94.